# -*- coding: utf-8 -*-

"""
@author: 
@contact: 
@Created on: 2024/04/29
@Remark: 岗位管理
"""
from rest_framework import serializers
from dvadmin.utils.serializers import CustomModelSerializer
from dvadmin.utils.viewset import CustomModelViewSet
from dvadmin.system.models import Post


class PostSerializer(CustomModelSerializer):
    """
    岗位-序列化器
    """

    class Meta:
        model = Post
        fields = "__all__"
        read_only_fields = ["id"]


class PostCreateUpdateSerializer(CustomModelSerializer):
    """
    岗位管理 创建/更新时的序列化器
    """

    class Meta:
        model = Post
        fields = "__all__"


class PostViewSet(CustomModelViewSet):
    """
    岗位管理接口
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = Post.objects.all()
    serializer_class = PostSerializer
    create_serializer_class = PostCreateUpdateSerializer
    update_serializer_class = PostCreateUpdateSerializer
    filter_fields = ['name', 'code', 'status'] 